/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Menu.java
 *
 * Created on 23/Nov/2011, 16:30:55
 */
package desint;

import java.awt.CardLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

/**
 *
 * @author lenny
 */
public class Menu extends javax.swing.JPanel {
    
    private int isSelectedUtil;
    private int isSelectedAtividade;
    private int isSelectedExercicio;
    private int isSelectedExercicioCat;
    private int isSelectedEspacofisico;
    private int isSelectedAgenda;
    public JanelaPrincipal janelaprincipal;
    private CardLayout cardlayout;

    /** Creates new form Menu */
    public Menu() {
        initComponents();
        isSelectedUtil=0;
        isSelectedAtividade=0;
        isSelectedExercicio=0;
        isSelectedExercicioCat=0;
        isSelectedEspacofisico=0;
        isSelectedAgenda=0;
        noneSelected();
    }
    
    private void noneSelected(){
        if ((isSelectedUtil==0) 
                && (isSelectedAtividade==0)
                && (isSelectedExercicio==0)
                && (isSelectedExercicioCat==0)
                && (isSelectedEspacofisico==0)
                && (isSelectedAgenda==0)){
                    ImageIcon icon = new ImageIcon("src/util_sel.png");
                    util.setIcon(icon);
                    isSelectedUtil = 1;
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        exercicioCat = new javax.swing.JLabel();
        exercicio = new javax.swing.JLabel();
        util = new javax.swing.JLabel();
        espacoFisico = new javax.swing.JLabel();
        agenda = new javax.swing.JLabel();
        atividade = new javax.swing.JLabel();
        background = new javax.swing.JLabel();

        exercicioCat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/exercicioCat.png"))); // NOI18N
        exercicioCat.setToolTipText("Categoria de Exercico");
        exercicioCat.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        exercicioCat.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                exercicioCatMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                exercicioCatMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                exercicioCatMouseExited(evt);
            }
        });
        exercicioCat.setBounds(20, 230, 60, 60);
        jLayeredPane1.add(exercicioCat, javax.swing.JLayeredPane.DEFAULT_LAYER);

        exercicio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/exercicio.png"))); // NOI18N
        exercicio.setToolTipText("Exercicio");
        exercicio.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        exercicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                exercicioMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                exercicioMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                exercicioMouseExited(evt);
            }
        });
        exercicio.setBounds(20, 160, 60, 60);
        jLayeredPane1.add(exercicio, javax.swing.JLayeredPane.DEFAULT_LAYER);

        util.setIcon(new javax.swing.ImageIcon(getClass().getResource("/util.png"))); // NOI18N
        util.setToolTipText("Utilizador");
        util.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        util.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                utilMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                utilMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                utilMouseExited(evt);
            }
        });
        util.setBounds(20, 30, 50, 50);
        jLayeredPane1.add(util, javax.swing.JLayeredPane.DEFAULT_LAYER);

        espacoFisico.setIcon(new javax.swing.ImageIcon(getClass().getResource("/espacofis.png"))); // NOI18N
        espacoFisico.setToolTipText("Espaço Fisico");
        espacoFisico.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        espacoFisico.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                espacoFisicoMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                espacoFisicoMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                espacoFisicoMouseExited(evt);
            }
        });
        espacoFisico.setBounds(20, 300, 50, 50);
        jLayeredPane1.add(espacoFisico, javax.swing.JLayeredPane.DEFAULT_LAYER);

        agenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/agenda_icon.png"))); // NOI18N
        agenda.setToolTipText("Agenda");
        agenda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        agenda.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                agendaMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                agendaMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                agendaMouseExited(evt);
            }
        });
        agenda.setBounds(20, 370, 50, 50);
        jLayeredPane1.add(agenda, javax.swing.JLayeredPane.DEFAULT_LAYER);

        atividade.setIcon(new javax.swing.ImageIcon(getClass().getResource("/atividade.png"))); // NOI18N
        atividade.setToolTipText("Atividade");
        atividade.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        atividade.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                atividadeMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                atividadeMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                atividadeMouseExited(evt);
            }
        });
        atividade.setBounds(20, 100, 50, 50);
        jLayeredPane1.add(atividade, javax.swing.JLayeredPane.DEFAULT_LAYER);

        background.setIcon(new javax.swing.ImageIcon(getClass().getResource("/back_menu.png"))); // NOI18N
        background.setBounds(0, 0, 110, 480);
        jLayeredPane1.add(background, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 481, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void utilMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_utilMouseEntered
        if (isSelectedUtil == 0) {
            ImageIcon icon = new ImageIcon("src/util_mov.png");
            util.setIcon(icon);
        }
    }//GEN-LAST:event_utilMouseEntered

    private void utilMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_utilMouseExited
        if (isSelectedUtil == 0) {
            ImageIcon icon = new ImageIcon("src/util.png");
            util.setIcon(icon);
        }
    }//GEN-LAST:event_utilMouseExited

    private void utilMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_utilMouseClicked
        ImageIcon icon = new ImageIcon("src/util_sel.png");
        util.setIcon(icon);
        isSelectedUtil = 1;
        cardlayout = (CardLayout)(janelaprincipal.cardHolder.getLayout());
        cardlayout.show(janelaprincipal.cardHolder, "menuUtil");
        
        /*    UNSELECT              */
        isSelectedExercicio=0;
        icon = new ImageIcon("src/exercicio.png");
        exercicio.setIcon(icon);
        isSelectedExercicioCat=0;
        icon = new ImageIcon("src/exercicioCat.png");
        exercicioCat.setIcon(icon);
        isSelectedEspacofisico=0;
        icon = new ImageIcon("src/espacofis.png");
        espacoFisico.setIcon(icon);
        isSelectedAgenda = 0;
        icon = new ImageIcon("src/agenda_icon.png");
        agenda.setIcon(icon);
        isSelectedAtividade = 0;
        icon = new ImageIcon("src/atividade.png");
        atividade.setIcon(icon);
    }//GEN-LAST:event_utilMouseClicked

    private void exercicioMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exercicioMouseEntered
        if (isSelectedExercicio == 0) {
            ImageIcon icon = new ImageIcon("src/exercicio_mov.png");
            exercicio.setIcon(icon);
        }
    }//GEN-LAST:event_exercicioMouseEntered

    private void exercicioMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exercicioMouseExited
         if (isSelectedExercicio == 0) {
            ImageIcon icon = new ImageIcon("src/exercicio.png");
            exercicio.setIcon(icon);
        }
    }//GEN-LAST:event_exercicioMouseExited

    private void exercicioMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exercicioMouseClicked
        ImageIcon icon = new ImageIcon("src/exercicio_sel.png");
        exercicio.setIcon(icon);
        isSelectedExercicio = 1;
        cardlayout = (CardLayout)(janelaprincipal.cardHolder.getLayout());
        cardlayout.show(janelaprincipal.cardHolder, "menuExercicio");

        /*    UNSELECT              */
        isSelectedUtil = 0;
        icon = new ImageIcon("src/util.png");
        util.setIcon(icon);
        isSelectedExercicioCat=0;
        icon = new ImageIcon("src/exercicioCat.png");
        exercicioCat.setIcon(icon);
        isSelectedEspacofisico=0;
        icon = new ImageIcon("src/espacofis.png");
        espacoFisico.setIcon(icon);
        isSelectedAgenda = 0;
        icon = new ImageIcon("src/agenda_icon.png");
        agenda.setIcon(icon);
        isSelectedAtividade = 0;
        icon = new ImageIcon("src/atividade.png");
        atividade.setIcon(icon);
    }//GEN-LAST:event_exercicioMouseClicked

    private void exercicioCatMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exercicioCatMouseEntered
        if (isSelectedExercicioCat == 0) {
            ImageIcon icon = new ImageIcon("src/exercicioCat_mov.png");
            exercicioCat.setIcon(icon);
        }
    }//GEN-LAST:event_exercicioCatMouseEntered

    private void exercicioCatMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exercicioCatMouseExited
       if (isSelectedExercicioCat == 0) {
            ImageIcon icon = new ImageIcon("src/exercicioCat.png");
            exercicioCat.setIcon(icon);
        }
    }//GEN-LAST:event_exercicioCatMouseExited

    private void exercicioCatMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exercicioCatMouseClicked
        ImageIcon icon = new ImageIcon("src/exercicioCat_sel.png");
        exercicioCat.setIcon(icon);
        isSelectedExercicioCat = 1;
        cardlayout = (CardLayout)(janelaprincipal.cardHolder.getLayout());
        cardlayout.show(janelaprincipal.cardHolder, "menuExerciciocat");
        
        

        /*    UNSELECT              */
        isSelectedUtil = 0;
        icon = new ImageIcon("src/util.png");
        util.setIcon(icon);
        isSelectedExercicio = 0;
        icon = new ImageIcon("src/exercicio.png");
        exercicio.setIcon(icon);
        isSelectedEspacofisico = 0;
        icon = new ImageIcon("src/espacofis.png");
        espacoFisico.setIcon(icon);
        isSelectedAgenda = 0;
        icon = new ImageIcon("src/agenda_icon.png");
        agenda.setIcon(icon);
        isSelectedAtividade = 0;
        icon = new ImageIcon("src/atividade.png");
        atividade.setIcon(icon);
    }//GEN-LAST:event_exercicioCatMouseClicked

    private void espacoFisicoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_espacoFisicoMouseClicked
        ImageIcon icon = new ImageIcon("src/espacofis_sel.png");
        espacoFisico.setIcon(icon);
        isSelectedEspacofisico = 1;
        cardlayout = (CardLayout) (janelaprincipal.cardHolder.getLayout());
        cardlayout.show(janelaprincipal.cardHolder, "menuEspacofisico");

        /*    UNSELECT              */
        isSelectedUtil = 0;
        icon = new ImageIcon("src/util.png");
        util.setIcon(icon);
        isSelectedExercicio=0;
        icon = new ImageIcon("src/exercicio.png");
        exercicio.setIcon(icon);
        isSelectedExercicioCat = 0;
        icon = new ImageIcon("src/exercicioCat.png");
        exercicioCat.setIcon(icon);
        isSelectedAgenda = 0;
        icon = new ImageIcon("src/agenda_icon.png");
        agenda.setIcon(icon);
        isSelectedAtividade = 0;
        icon = new ImageIcon("src/atividade.png");
        atividade.setIcon(icon);
    }//GEN-LAST:event_espacoFisicoMouseClicked

    private void espacoFisicoMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_espacoFisicoMouseEntered
        if (isSelectedEspacofisico == 0) {
            ImageIcon icon = new ImageIcon("src/espacofis_mov.png");
            espacoFisico.setIcon(icon);
        }
    }//GEN-LAST:event_espacoFisicoMouseEntered

    private void espacoFisicoMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_espacoFisicoMouseExited
        if (isSelectedEspacofisico == 0) {
            ImageIcon icon = new ImageIcon("src/espacofis.png");
            espacoFisico.setIcon(icon);
        }
    }//GEN-LAST:event_espacoFisicoMouseExited

    private void agendaMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_agendaMouseEntered
        if (isSelectedAgenda == 0) {
            ImageIcon icon = new ImageIcon("src/agenda_mov.png");
            agenda.setIcon(icon);
        }
    }//GEN-LAST:event_agendaMouseEntered

    private void agendaMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_agendaMouseExited
        if (isSelectedAgenda == 0) {
            ImageIcon icon = new ImageIcon("src/agenda_icon.png");
            agenda.setIcon(icon);
        }
    }//GEN-LAST:event_agendaMouseExited

    private void agendaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_agendaMouseClicked
       ImageIcon icon = new ImageIcon("src/agenda_sel.png");
        agenda.setIcon(icon);
        isSelectedAgenda = 1;
        cardlayout = (CardLayout) (janelaprincipal.cardHolder.getLayout());
        cardlayout.show(janelaprincipal.cardHolder, "menuAgenda");

        /*    UNSELECT              */
        isSelectedUtil = 0;
        icon = new ImageIcon("src/util.png");
        util.setIcon(icon);
        isSelectedExercicio=0;
        icon = new ImageIcon("src/exercicio.png");
        exercicio.setIcon(icon);
        isSelectedExercicioCat = 0;
        icon = new ImageIcon("src/exercicioCat.png");
        exercicioCat.setIcon(icon);
        isSelectedEspacofisico = 0;
        icon = new ImageIcon("src/espacofis.png");
        espacoFisico.setIcon(icon);
        isSelectedAtividade = 0;
        icon = new ImageIcon("src/atividade.png");
        atividade.setIcon(icon);
    }//GEN-LAST:event_agendaMouseClicked

    private void atividadeMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_atividadeMouseEntered
        if (isSelectedAtividade == 0) {
            ImageIcon icon = new ImageIcon("src/atividade_mov.png");
            atividade.setIcon(icon);
        }
    }//GEN-LAST:event_atividadeMouseEntered

    private void atividadeMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_atividadeMouseExited
        if (isSelectedAtividade == 0) {
            ImageIcon icon = new ImageIcon("src/atividade.png");
            atividade.setIcon(icon);
        }
    }//GEN-LAST:event_atividadeMouseExited

    private void atividadeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_atividadeMouseClicked
         ImageIcon icon = new ImageIcon("src/atividade_sel.png");
        atividade.setIcon(icon);
        isSelectedAtividade = 1;
        cardlayout = (CardLayout) (janelaprincipal.cardHolder.getLayout());
        cardlayout.show(janelaprincipal.cardHolder, "menuAtividade");

        /*    UNSELECT              */
        isSelectedUtil = 0;
        icon = new ImageIcon("src/util.png");
        util.setIcon(icon);
        isSelectedExercicio=0;
        icon = new ImageIcon("src/exercicio.png");
        exercicio.setIcon(icon);
        isSelectedExercicioCat = 0;
        icon = new ImageIcon("src/exercicioCat.png");
        exercicioCat.setIcon(icon);
        isSelectedEspacofisico = 0;
        icon = new ImageIcon("src/espacofis.png");
        espacoFisico.setIcon(icon);
        isSelectedAgenda = 0;
        icon = new ImageIcon("src/agenda_icon.png");
        agenda.setIcon(icon);
        
    }//GEN-LAST:event_atividadeMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel agenda;
    private javax.swing.JLabel atividade;
    private javax.swing.JLabel background;
    private javax.swing.JLabel espacoFisico;
    private javax.swing.JLabel exercicio;
    private javax.swing.JLabel exercicioCat;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLabel util;
    // End of variables declaration//GEN-END:variables

   
}
